package co.yixiang.yshop.module.product.controller.app.product;


import co.yixiang.yshop.framework.common.pojo.CommonResult;
import co.yixiang.yshop.module.product.controller.app.category.vo.AppCategoryRespVO;
import co.yixiang.yshop.module.product.controller.app.product.param.AppStoreProductQueryParam;
import co.yixiang.yshop.module.product.controller.app.product.vo.AppStoreProductRespVo;
import co.yixiang.yshop.module.product.service.storeproduct.AppStoreProductService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.*;

import static co.yixiang.yshop.framework.common.pojo.CommonResult.success;

/**
 * <p>
 * 商品控制器
 * </p>
 *
 * @author hupeng
 * @since 2023-8-16
 */
@Slf4j
@RestController
@Tag(name = "用户 APP - 商品")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
@RequestMapping("/product")
public class AppStoreProductController {

    private final AppStoreProductService storeProductService;


    /**
     * 获取产品列表
     */
    @GetMapping("/products")
    @Operation(summary = "商品列表")
    public CommonResult<List<AppCategoryRespVO>> goodsList(AppStoreProductQueryParam productQueryParam){
        try {
            Thread.sleep(2000L);
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
        }
        return success(storeProductService.getGoodsList(productQueryParam));
    }

    /**
     * 获取产品详情
     */
    @GetMapping("/detail/{id}")
    @Operation(summary = "获取产品详情")
    public CommonResult<AppStoreProductRespVo> goodsDetail(@PathVariable Long id){
        return success(storeProductService.getStoreProductById(id));
    }

    @GetMapping("/recommond")
    @Operation(summary = "商品建议")
    public String recommond(){
        List<String> set = new ArrayList<>(List.of(
                "根据您的反馈，不太喜欢太甜呢～这次我们为您调整了糖度，试试看吧！",
                "您偏好清爽口感，今天的新品正好低糖轻盈，很适合您哦～",
                "天气转凉，来杯温热醇厚的饮品暖暖身子吧！",
                "看您常选低卡选项，这款用天然代糖调制的饮品或许合您心意～",
                "喜欢茶香突出又不腻口？这杯刚刚好，回甘清新～",
                "您钟爱浓郁咖啡风味，这次的萃取方式会让香气更饱满哦！",
                "上次提到配料偏硬，今天我们特别优化了口感，软糯顺滑～",
                "阳光正好，来点带果香的清爽搭配，唤醒好心情吧！",
                "您是植物奶爱好者？这次用了更丝滑的新配方，值得一试～",
                "不想摄入太多咖啡因？我们有温和提神的无因选项，安心享用～",
                "根据您的口味习惯，少糖+温热的组合可能会更合您胃口～",
                "下午容易犯困？一杯顺滑提神的冷饮，帮您轻松续上能量！",
                "这款甜感来自天然食材，甜而不齁，很多像您一样讲究口感的客人都很喜欢～",
                "今日水果特别新鲜，酸甜平衡刚刚好，清爽解腻～",
                "您喜欢奶香浓郁的口感，这次的奶基底升级后更醇厚顺口～",
                "新鲜现制，果香扑鼻，这一杯特别适合想换换口味的您～",
                "会员专属推荐：根据您的点单记录，我们悄悄为您预留了定制风味～",
                "咖啡与茶的巧妙融合，苦甜平衡，层次丰富，不妨尝尝看？",
                "秋冬限定风味上线，加入温暖辛香，喝一口就暖心～",
                "看您常和朋友一起来，双人搭配组合既丰富又划算，今天试试新组合吧！"
        ));
        Random random = new Random();
        int i = random.nextInt(0, set.size());
        return set.get(i);
    }

    record Suggest(String message){
    }

    @PostMapping("/suggest")
    public Boolean suggest(@RequestBody Suggest suggest){
        return true;
    }










}

